package com.veo.aop;

import jdk.nashorn.internal.ir.JoinPredecessor;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Order(1)
public class UserAop {

    @Before("execution(* com.veo.service.UserService.addUser(..))")
    public void before(){
        System.out.println("前置通知......");
    }

    @AfterReturning("execution(* com.veo.service.UserService.delUser(..))")
    public void afterReturning(){
        System.out.println("后置通知......");
    }

    @Around("execution(* com.veo.service.UserService.findAllUsers(..))")
    public void around(ProceedingJoinPoint joinPredecessor) throws Throwable {
        System.out.println("环绕前......");
        joinPredecessor.proceed();
        System.out.println("环绕后......");
    }

    @After("pointcut1()")
    public void after(){
        System.out.println("最终通知......");
    }

    @AfterThrowing("pointcut2()")
    public void afterThrowing(){
        System.out.println("异常通知");
    }

    @Pointcut("execution(* com.veo.service.UserService.updateUserById(..))")
    public void pointcut1(){

    }

    @Pointcut("execution(* com.veo.service.UserService.findUserByNameAndPwd(..))")
    public void pointcut2(){}



}
